#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

class Solution
{
public:
    vector<int> twoSum(vector<int>& nums, int target)
    {
        unordered_map <int, int> hash;
        for (int i = 0; i < nums.size(); i++)
        {
            int tmp = target - nums[i];
            if (hash.count(tmp)) return { hash[tmp],i };
            //hash.insert({nums[i],i});
            hash[nums[i]] = i;
        }
        return { -1,-1 };
    }
};


class Solution
{
public:
    vector<int> twoSum(vector<int>& nums, int target)
    {
        vector<int> ret;
        for (int i = 1; i < nums.size(); i++)
        {
            for (int j = i - 1; j >= 0; j--)
            {
                if (nums[i] + nums[j] == target)
                {
                    ret.push_back(i);
                    ret.push_back(j);
                    return ret;
                }
            }
        }
        return ret;
    }
};